package com.exercise.widgets.dialog.dialogfragment

import android.app.Dialog
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import com.exercise.widgets.R

class ListDialogFragment : DialogFragment() {
    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        val dataArray = resources.getStringArray(R.array.arrayData)
        return activity?.let {
            val builder = AlertDialog.Builder(it)
            builder
                .setTitle("Title")
//                .setMessage("Start game")

//                .setItems(dataArray) { dialog, which ->
//                    Toast.makeText(it, dataArray[which], Toast.LENGTH_SHORT).show()
//                }
//                .setSingleChoiceItems(dataArray, 1) { dialog, which ->
//                    Toast.makeText(it, dataArray[which], Toast.LENGTH_SHORT).show()
//                }
                .setMultiChoiceItems(dataArray,null){dialog,which,isChecked->

                }
                .setPositiveButton("Start") { dialog, id ->
                    Toast.makeText(it, "Start", Toast.LENGTH_SHORT).show()
                }
                .setNeutralButton("Neutral") { dialog, id ->
                    Toast.makeText(it, "Neutral", Toast.LENGTH_SHORT).show()
                }
                .setNegativeButton("Cancel") { dialog, id ->
                    Toast.makeText(it, "Cancel", Toast.LENGTH_SHORT).show()

                }
            builder.create()
        } ?: throw IllegalStateException("Activity can not be null")
    }
}